/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-11-20
 * Time: 11:04
 */

import java.io.*;
import java.util.Arrays;


public class Test4 {

    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        int cnt = 1;
        while (true) {
            in.nextToken();
            int n = (int) in.nval;
            in.nextToken();
            int m = (int) in.nval;
            if (n == 0 && m == 0) return;
            int[] fa = new int[n + 1];
            int[] size = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                fa[i] = i;
                size[i] = 1;
            }

            for (int i = 1; i <= m; ++i) {
                in.nextToken();
                int x = (int) in.nval;
                in.nextToken();
                int y = (int) in.nval;
                merge(x, y, fa, size);
            }
            int num = 0;
            for (int i = 1; i <= n; ++i) {
                if (fa[i] == i) num++;
            }
            System.out.println("Case " + cnt + ": " + num);
            cnt++;
        }
    }

    public static void merge(int x, int y, int[] fa, int[] size) {
        int xfa = findfa(x, fa);
        int yfa = findfa(y, fa);
        if (xfa == yfa) return;
        if (size[xfa] > size[yfa]) {
            size[xfa] += size[yfa];
            fa[yfa] = xfa;
        } else {
            size[yfa] += size[xfa];
            fa[xfa] = yfa;
        }
    }

    public static int findfa(int x, int[] fa) {
        if (fa[x] == x) return x;
        else fa[x] = findfa(fa[x], fa);
        return fa[x];
    }
}
